<?php

function getLocation() {
     global $dbna;
    $locations = $dbna->get_results("SELECT * FROM location");
    return $locations; 
}
function selectLocation ($selected = null) {
    $locations = getLocation();
    $options = '';
    foreach($locations as $l) {
        if ($l->id == $selected) {
            $options .= sprintf('<option value="%d" selected="selected">%s</option>', $l->id, $l->location);
        } else {
            $options .= sprintf('<option value="%d">%s</option>', $l->id, $l->location);
        }
        
    }
    return $options;
    
}
function getStatus() {
     global $dbna;
    $status = $dbna->get_results("SELECT * FROM tracking_status");
    return $status; 
}
function selectStatus ($selected = null) {
    $status = getStatus();
    
    $options = '';
    foreach($status as $s) {
        if ($s->id == $selected) {
            $options .= sprintf('<option value="%d" selected="selected">%s</option>', $s->id, $s->status);
        } else {
            $options .= sprintf('<option value="%d">%s</option>', $s->id, $s->status);
        }
        
    }
    return $options;
    //return sprintf('<select name="location_id">%s</select>', $options);
}
?>
